home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / Developer Essentials May91 / MPW Interfaces & Libraries 3.2 / AIncludes / MIDI.a < prev    next >
Encoding:
Text File  |  1991-04-17  |  11.3 KB  |  480 lines  |  [TEXT/MPS ]

  1. ; Version: 3.02
  2. ; Created: Friday, October 20, 1989 at 9:31:29 PM
  3.  
  4. ;;;
  5. ;;; MIDI.a
  6. ;;;
  7. ;;; This file contains the assembly-language interface for the MIDI Manager.
  8. ;;;
  9. ;;; Author: John Worthington, Don Marsh, Mark Lentczner
  10. ;;; Copyright © 1988, Apple Computer, Inc.
  11. ;;; All Rights Reserved
  12. ;;;
  13.  
  14.     IF &TYPE('__IncludingMIDI__') = 'UNDEFINED' THEN
  15. __IncludingMIDI__    SET    1
  16.  
  17.  
  18.  
  19. ;;; _______________________________________________________________________________
  20. ;;;
  21. ;;;  Constants:
  22. ;;;
  23.  
  24. midiToolNum       EQU         4                         ; tool number of MIDI Mgr for SndDispVersion call.
  25. midiMaxNameLen    EQU         31                        ; maximum number of characters in port and client names
  26.  
  27.  
  28. ; Time formats
  29.  
  30. midiFormatMSec    EQU         0                         ; milliseconds
  31. midiFormatBeats   EQU         1                         ; beats
  32. midiFormat24fpsBit EQU        2                         ; 24 frames/sec.
  33. midiFormat25fpsBit EQU        3                         ; 25 frames/sec.
  34. midiFormat30fpsDBit EQU       4                         ; 30 frames/sec. drop-frame
  35. midiFormat30fpsBit EQU        5                         ; 30 frames/sec.
  36. midiFormat24fpsQF EQU         6                         ; 24 frames/sec. longInt format
  37. midiFormat25fpsQF EQU         7                         ; 25 frames/sec. longInt format
  38. midiFormat30fpsDQF EQU        8                         ; 30 frames/sec. drop-frame longInt format
  39. midiFormat30fpsQF EQU         9                         ; 30 frames/sec. longInt format
  40. midiInternalSync  EQU         0                         ; internally synced
  41. midiExternalSync  EQU         1                         ; externally synced
  42.  
  43.  
  44. ; Port types
  45.  
  46. midiPortTypeTime  EQU         0                         ; time port
  47. midiPortTypeInput EQU         1                         ; input port
  48. midiPortTypeOutput EQU        2                         ; output port
  49. midiPortTypeTimeInv EQU       3                         ; invisible time port
  50.  
  51.  
  52. ; OffsetTimes
  53.  
  54. midiGetEverything EQU         $7FFFFFFF                 ; get all packets, regardless of time stamps
  55. midiGetNothing    EQU         $80000000                 ; get no packets, regardless of time stamps
  56. midiGetCurrent    EQU         $00000000                 ; get current packets only
  57.  
  58.  
  59.  
  60. ;;;
  61. ;;; MIDI data and messages are passed in MIDIPacket records (see below).
  62. ;;; The first byte of every MIDIPacket contains a set of flags
  63. ;;;
  64. ;;; bits 0-1   00 = new MIDIPacket, not continued
  65. ;;;                01 = begining of continued MIDIPacket
  66. ;;;                10 = end of continued MIDIPacket
  67. ;;;                11 = continuation
  68. ;;; bits 2-3            reserved
  69. ;;;
  70. ;;;bits 4-6  000 = MIDIPacket contains MIDI data
  71. ;;;               001 = MIDIPacket contains MIDI Manager message
  72. ;;;
  73. ;;;  bit 7            0 = MIDIPacket has valid stamp
  74. ;;;                   1 = stamp with current clock
  75. ;;;
  76.  
  77. midiContMask      EQU         $03
  78. midiNoCont        EQU         $00
  79. midiStartCont     EQU         $01
  80. midiMidCont       EQU         $03
  81. midiEndCont       EQU         $02
  82. midiTypeMask      EQU         $70
  83. midiMsgType       EQU         $00
  84. midiMgrType       EQU         $10
  85. midiTimeStampMask EQU         $80
  86. midiTimeStampCurrent EQU      $80
  87. midiTimeStampValid EQU        $00
  88.  
  89.  
  90. ;  MIDI Manager MIDIPacket command words (the first word in the data field
  91. ;  for midiMgrType messages)
  92.  
  93. midiOverflowErr   EQU         $0001
  94. midiSCCErr        EQU         $0002
  95. midiPacketErr     EQU         $0003
  96. midiMaxErr        EQU         $00FF                     ; all command words less than this value
  97. ;    are error indicators
  98.  
  99. ;;; _______________________________________________________________________________
  100. ;;;
  101. ;;;  valid results to be returned from readHooks
  102. ;;;
  103.  
  104. midiKeepPacket    EQU         0
  105. midiMorePacket    EQU         1
  106. midiNoMorePacket  EQU         2
  107.  
  108.  
  109. ;;; _______________________________________________________________________________
  110. ;;;
  111. ;;;  Errors:
  112. ;;;
  113.  
  114. midiNoClientErr   EQU         -250                      ; no client with that ID found
  115. midiNoPortErr     EQU         -251                      ; no port with that ID found
  116. midiTooManyPortsErr EQU       -252                      ; too many ports already installed in the system
  117. midiTooManyConsErr EQU        -253                      ; too many connections made
  118. midiVConnectErr   EQU         -254                      ; pending virtual connection created
  119. midiVConnectMade  EQU         -255                      ; pending virtual connection resolved
  120. midiVConnectRmvd  EQU         -256                      ; pending virtual connection removed
  121. midiNoConErr      EQU         -257                      ; no connection exists between specified ports
  122. midiWriteErr      EQU         -258                      ; MIDIWritePacket couldn't write to all connected ports
  123. midiNameLenErr    EQU         -259                      ; name supplied is longer than 31 characters
  124. midiDupIDErr      EQU         -260                      ; duplicate client ID
  125. midiInvalidCmdErr EQU         -261                      ; command not supported for port type
  126.  
  127.  
  128. ;;; _______________________________________________________________________________
  129. ;;;
  130. ;;;  Driver calls:
  131. ;;;
  132.  
  133. midiOpenDriver    EQU         1
  134. midiCloseDriver   EQU         2
  135.  
  136.  
  137.  
  138. ;;; ________________________________________________________________________________
  139. ;;;
  140. ;;;  MIDI data and other messages are read and written in packets:
  141. ;;;
  142.  
  143. MIDIPacket        RECORD      0
  144. flags             DS.B        1
  145. len               DS.B        1
  146. tStamp            DS.L        1
  147. data              EQU         *
  148.                   ENDR
  149.  
  150.  
  151. ;;; _______________________________________________________________________________
  152. ;;;
  153. ;;;  port information
  154. ;;;
  155.  
  156. MIDIIDRec         RECORD      0
  157. clientID          DS.L        1
  158. portID            DS.L        1
  159.                   ENDR
  160.  
  161. MIDIPortParams    RECORD      0
  162. portID            DS.L        1                         ; ID of port, unique within client
  163. portType          DS.W        1                         ; Type of port - input, output, time, etc.
  164. timeBase          DS.W        1                         ; refnum of time base, 0 if none
  165. offsetTime        DS.L        1                         ; offset for current time stamps
  166. readHook          DS.L        1                         ; routine to call when input data is valid
  167. refCon            DS.L        1                         ; refcon for port (for client use)
  168. sync              DS.W        1                         ; internal, external,other
  169. curTime           DS.L        1                         ; current local time for the port
  170. format            DS.W        1                         ; time code format in use
  171. name              DS.B        256                       ; name of the port. This is a real live string, not a ptr.
  172.  
  173. size              EQU         *                         ; size of port params
  174.                   ENDR
  175.  
  176. MIDIPortInfo      RECORD      0
  177. portType          DS.W        1                         ; type of port
  178. timeBase          DS.L        2                         ; MIDIIDRec for time base
  179. numConnects       DS.W        1                         ; number of connections
  180. cList             EQU         *                         ; ARRAY [1..numConnects] of MIDIIDRec
  181.                   ENDR
  182.  
  183.  
  184. ;;; _______________________________________________________________________________
  185. ;;;
  186. ;;; Clocks:
  187. ;;;
  188.  
  189. MIDIClkInfo       RECORD      0
  190. sync              DS.W        1                         ; 0 = internal,  1 = external
  191. curTime           DS.L        1                         ; current value of port's clock
  192. format            DS.W        1                         ; time code format
  193. size              EQU         *                         ; size of MIDIClkInfo
  194.                   ENDR
  195.  
  196.  
  197. ;;; _______________________________________________________________________________
  198. ;;;
  199. ;;;  Equates for function selectors
  200. ;;;
  201.  
  202. midiVersion       EQU         0
  203. midiSignIn        EQU         4
  204. midiSignOut       EQU         8
  205. midiGetClients    EQU         12
  206. midiGetClientName EQU         16
  207. midiSetClientName EQU         20
  208. midiGetPorts      EQU         24
  209. midiAddPort       EQU         28
  210. midiGetPortInfo   EQU         32
  211. midiConnectData   EQU         36
  212. midiUnConnectData EQU         40
  213. midiConnectTime   EQU         44
  214. midiUnConnectTime EQU         48
  215. midiFlush         EQU         52
  216. midiGetReadHook   EQU         56
  217. midiSetReadHook   EQU         60
  218. midiGetPortName   EQU         64
  219. midiSetPortName   EQU         68
  220. midiWakeUp        EQU         72
  221. midiRemovePort    EQU         76
  222. midiGetSync       EQU         80
  223. midiSetSync       EQU         84
  224. midiGetCurTime    EQU         88
  225. midiSetCurTime    EQU         92
  226. midiStartTime     EQU         96
  227. midiStopTime      EQU         100
  228. midiPoll          EQU         104
  229. midiWritePacket   EQU         108
  230. midiWorldChanged  EQU         112
  231. midiGetOffsetTime EQU         116
  232. midiSetOffsetTime EQU         120
  233. midiConvertTime   EQU         124
  234. midiGetRefCon     EQU         128
  235. midiSetRefCon     EQU         132
  236. midiGetClRefCon   EQU         136
  237. midiSetClRefCon   EQU         140
  238. midiGetTCFormat   EQU         144
  239. midiSetTCFormat   EQU         148
  240. midiSetRunRate    EQU         152
  241. midiGetClientIcon EQU         156
  242.  
  243.  
  244. ;;; ________________________________________________________________________________
  245. ;;;
  246. ;;; Call Macros for Assembly
  247. ;;;
  248.  
  249.                                                         ;;
  250.                                                         ;;    fake _SndDispVersion which calls glue to make sure that the sound
  251.                                                         ;;    dispatcher has been installed
  252.                                                         ;;
  253.                   MACRO
  254. &label            _SndDispVersion
  255.                   IMPORT      SndDispVersion
  256. &label            JSR         SndDispVersion    
  257.                                                         ; call the sound dispatcher glue in MIDIGlue.o
  258.                   ENDM
  259.  
  260.  
  261.                   MACRO
  262. &label            _CallMIDIMgr &selector
  263. &label            MOVE.L      #(&selector<<16)+midiToolNum,D0
  264.                   _SoundDispatch
  265.                   ENDM
  266.  
  267.  
  268.                   MACRO
  269. &label            _MIDISignIn
  270. &label            _CallMIDIMgr midiSignIn
  271.                   MEND
  272.  
  273.                   MACRO
  274. &label            _MIDISignOut
  275. &label            _CallMIDIMgr midiSignOut
  276.                   MEND
  277.  
  278.                   MACRO
  279. &label            _MIDIVersion
  280. &label            _CallMIDIMgr midiVersion
  281.                   MEND
  282.  
  283.                   MACRO
  284. &label            _MIDIGetClients
  285. &label            _CallMIDIMgr midiGetClients
  286.                   MEND
  287.  
  288.                   MACRO
  289. &label            _MIDIGetClientName
  290. &label            _CallMIDIMgr midiGetClientName
  291.                   MEND
  292.  
  293.                   MACRO
  294. &label            _MIDISetClientName
  295. &label            _CallMIDIMgr midiSetClientName
  296.                   MEND
  297.  
  298.                   MACRO
  299. &label            _MMGetClientIcon
  300. &label            _CallMIDIMgr nGetClientIcon
  301.                   MEND
  302.  
  303.                   MACRO
  304. &label            _MIDIGetPorts
  305. &label            _CallMIDIMgr midiGetPorts
  306.                   MEND
  307.                   MACRO
  308. &label            _MIDIAddPort
  309. &label            _CallMIDIMgr midiAddPort
  310.                   MEND
  311.  
  312.  
  313.                   MACRO
  314. &label            _MIDIGetPortInfo
  315. &label            _CallMIDIMgr midiGetPortInfo
  316.                   MEND
  317.  
  318.                   MACRO
  319. &label            _MIDIConnectData
  320. &label            _CallMIDIMgr midiConnectData
  321.                   MEND
  322.  
  323.  
  324.                   MACRO
  325. &label            _MIDIUnConnectData
  326. &label            _CallMIDIMgr midiUnConnectData
  327.                   MEND
  328.  
  329.                   MACRO
  330. &label            _MIDIConnectTime
  331. &label            _CallMIDIMgr midiConnectTime
  332.                   MEND
  333.  
  334.                   MACRO
  335. &label            _MIDIUnConnectTime
  336. &label            _CallMIDIMgr midiUnConnectTime
  337.                   MEND
  338.  
  339.                   MACRO
  340. &label            _MIDIFlush
  341. &label            _CallMIDIMgr midiFlush
  342.                   MEND
  343.  
  344.                   MACRO
  345. &label            _MIDIGetReadHook
  346. &label            _CallMIDIMgr midiGetReadHook
  347.                   MEND
  348.  
  349.                   MACRO
  350. &label            _MIDISetReadHook
  351. &label            _CallMIDIMgr midiSetReadHook
  352.                   MEND
  353.  
  354.                   MACRO
  355. &label            _MIDIGetPortName
  356. &label            _CallMIDIMgr midiGetPortName
  357.                   MEND
  358.  
  359.                   MACRO
  360. &label            _MIDISetPortName
  361. &label            _CallMIDIMgr midiSetPortName
  362.                   MEND
  363.  
  364.                   MACRO
  365. &label            _MIDIWakeUp
  366. &label            _CallMIDIMgr midiWakeUp
  367.                   MEND
  368.  
  369.                   MACRO
  370. &label            _MIDIRemovePort
  371. &label            _CallMIDIMgr midiRemovePort
  372.                   MEND
  373.  
  374.                   MACRO
  375. &label            _MIDIGetSync
  376. &label            _CallMIDIMgr midiGetSync
  377.                   MEND
  378.  
  379.  
  380.  
  381.  
  382.  
  383.                   MACRO
  384. &label            _MIDISetSync
  385. &label            _CallMIDIMgr midiSetSync
  386.                   MEND
  387.  
  388.                   MACRO
  389. &label            _MIDIGetCurTime
  390. &label            _CallMIDIMgr midiGetCurTime
  391.                   MEND
  392.  
  393.                   MACRO
  394. &label            _MIDISetCurTime
  395. &label            _CallMIDIMgr midiSetCurTime
  396.                   MEND
  397.  
  398.                   MACRO
  399. &label            _MIDIStartTime
  400. &label            _CallMIDIMgr midiStartTime
  401.                   MEND
  402.  
  403.                   MACRO
  404. &label            _MIDIStopTime
  405. &label            _CallMIDIMgr midiStopTime
  406.                   MEND
  407.  
  408.                   MACRO
  409. &label            _MIDIPoll
  410. &label            _CallMIDIMgr midiPoll
  411.                   MEND
  412.  
  413.                   MACRO
  414. &label            _MIDIWritePacket
  415. &label            _CallMIDIMgr midiWritePacket
  416.                   MEND
  417.  
  418.                   MACRO
  419. &label            _MIDIWorldChanged
  420. &label            _CallMIDIMgr midiWorldChanged
  421.                   MEND
  422.  
  423.                   MACRO
  424. &label            _MIDIGetOffsetTime
  425. &label            _CallMIDIMgr midiGetOffsetTime
  426.                   MEND
  427.  
  428.                   MACRO
  429. &label            _MIDISetOffsetTime
  430. &label            _CallMIDIMgr midiSetOffsetTime
  431.                   MEND
  432.  
  433.                   MACRO
  434. &label            _MIDIConvertTime
  435. &label            _CallMIDIMgr midiConvertTime
  436.                   MEND
  437.  
  438.                   MACRO
  439. &label            _MIDIGetRefCon
  440. &label            _CallMIDIMgr midiGetRefCon
  441.                   MEND
  442.  
  443.                   MACRO
  444. &label            _MIDISetRefCon
  445. &label            _CallMIDIMgr midiSetRefCon
  446.                   MEND
  447.  
  448.                   MACRO
  449. &label            _MIDIGetClRefCon
  450. &label            _CallMIDIMgr midiGetClRefCon
  451.                   MEND
  452.  
  453.                   MACRO
  454. &label            _MIDISetClRefCon
  455. &label            _CallMIDIMgr midiSetClRefCon
  456.                   MEND
  457.  
  458.                   MACRO
  459. &label            _MIDIGetTCFormat
  460. &label            _CallMIDIMgr midiGetTCFormat
  461.                   MEND
  462.  
  463.                   MACRO
  464. &label            _MIDISetTCFormat
  465. &label            _CallMIDIMgr midiSetTCFormat
  466.                   MEND
  467.  
  468.                   MACRO
  469. &label            _MIDISetRunRate
  470. &label            _CallMIDIMgr midiSetRunRate
  471.                   MEND
  472.  
  473.                   MACRO
  474. &label            _MIDIGetClientIcon
  475. &label            _CallMIDIMgr midiGetClientIcon
  476.                   MEND
  477.  
  478.  
  479.  
  480.     ENDIF    ; ...already included